<template>
  <div style="background-color: #42b983">
    <el-form :inline="true" :model="queryParams" ref="queryParams" class="demo-form-inline">
      <el-form-item label="登录地址">
        <el-input v-model="queryParams.loginLocation" placeholder="请输入登录地址" clearable></el-input>
      </el-form-item>
      <el-form-item label="用户名称">
        <el-input v-model="queryParams.nickname" placeholder="请输入用户名称" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="load">搜索</el-button>
        <el-button type="primary" icon="el-icon-refresh" @click="resetQueryParams">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
        :data="tableData"
        style="width: 100%">
      <el-table-column
          type="index"
          label="序号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="number"
          label="回话编号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="nickname"
          label="名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="department"
          label="部门名称"
          width="180">
      </el-table-column>

      <el-table-column
          prop="ip"
          label="Ip地址">
      </el-table-column>

      <el-table-column
          prop="loginLocation"
          label="登录地点">
      </el-table-column>

      <el-table-column
          prop="browserj"
          label="浏览器">
      </el-table-column>

      <el-table-column
          prop="system"
          label="操作系统">
      </el-table-column>


      <el-table-column
          prop="loginTime"
          label="登录时间">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.row)">强退
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <span class="demonstration">显示总数</span>
    <el-pagination
        @current-change="handleCurrentChange"
        :page-size="page.pageSize"
        layout="total, prev, pager, next"
        :total="page.total">
    </el-pagination>

  </div>
</template>

<script>
export default {
  name: "ListView",
  data() {
    return {
      queryParams:{},
      tableData: [],
      page: {
        pageNum: 1,
        pageSize: 2,
        total: 0,
      },
    }
  },
  created() {
    this.load();
  },
  methods: {
    resetQueryParams(){
      this.queryParams={}
      this.load()
    },
    load() {
      this.axios.post("/user/login/list/" + this.page.pageNum + "/" + this.page.pageSize,this.queryParams).then(resp => {
        this.tableData = resp.data;
        this.page.total = resp.data.length
        //this.page.total = resp.data.data.total;

      });
    },
    handleDelete() {
      this.axios.get("/user/login/qiangtui").then(resp => {
        localStorage.removeItem("token");
        this.$router.push("/")
        this.$message.success("强退成功");

      });
    },
    handleCurrentChange(val) {
      this.page.pageNum = val;
      this.load();
    },

  }

}
</script>

<style scoped>

</style>